#!/bin/bash

# usage
USAGE="Usage: $0"

# installation processes
PROCESSES='
CheckFun1
CheckFun2
InitFun1
InitFun2
'

# report error and quit
function Quit {
    [ -n "$1" ] && echo "$1!" > /dev/stderr
    echo -e "\033[31;1mInstallaion failed!\033[0m\n"
    exit 1
}

function CheckFun1 {
    echo ''
}

function CheckFun2 {
    echo ''
}

function InitFun1 {
    echo ''
}

function InitFun2 {
    echo ''
}

# execute every function in PROCESSES
function Main {
    for process in $PROCESSES; do
        echo -e "\n\033[33;1m- $func ...\033[0m"
        $process
    done
    echo -e "\033[32;1mInstall successfully!\033[0m\n"
}

# start here
# check root privilege
[ 0 -ne $UID ] && Quit "Can't run without ROOT"
# check arguments
[ 0 -ne $# ] && Quit "$USAGE"
# cd to script dir
cd $(dirname $0) || Quit
# install
Main

